package cn.littlehx.spring_boot_test2_2.service;

import cn.littlehx.spring_boot_test2_2.domain.Student;
import cn.littlehx.spring_boot_test2_2.repository.StudentRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public interface StudentService {
    List<Student> findALL();

    /**
     * 只支持分页的查询
     *
     * @param pageable
     * @return
     */
    Page<Student> findAll(Pageable pageable);

    /**
     * 实现动态查询
     * @param studentExample
     * @param pageable
     * @return
     */
    Page<Student> findAll( Example<Student> studentExample,Pageable pageable);

    /**
     * 按id进行查询
     *
     * @param id 主键,整数
     * @return
     */
    public Student findById(Integer id);

    /**
     * 按名字进行查询,like
     *
     * @param name 主键,整数
     * @return
     */
    public List<Student> findByNameLike(String name);

    /**
     * 按名字和密码进行查询
     *
     * @param name
     * @param password
     * @return
     */
    public List<Student> findByNameAndPassword(String name, String password) throws Exception;

    /**
     * 插入学生
     *
     * @param student
     */
    public Student insert(Student student);

    /**
     * 更新学生
     *
     * @param student
     */
    public Student update(Student student);

    /**
     * 删除学生
     *
     * @param id
     */
    public void delete(Integer id);
}
